//189000503 左香菊
//设置对联广告的宽、高、图片
var ad_width = "100px";
var ad_height = "250px";
var ad_img = "img/ad1.jpg";
var close_img = "img/close.png";

//创建广告容器的div
var ad_left = document.createElement("div");
ad_left.style.width = ad_width;
ad_left.style.height = ad_height;
ad_left.style.padding = "0px";
ad_left.style.position = "absolute";
ad_left.style.left = "30px";
ad_left.style.top = "20px";

//创建img元素，并加入到ad_left中，作为广告图片
var adimg = document.createElement("img");
adimg.src = ad_img;
ad_left.appendChild(adimg);

//创建关闭按钮，并加入到ad_left中
var closeimg = document.createElement("img");
closeimg.src = close_img;
closeimg.style.width = "50px";
closeimg.style.position = "relative";
closeimg.style.left = "50px";
closeimg.style.top = "-20px";
closeimg.style.cursor = "pointer";
ad_left.appendChild(closeimg);

//将ad_left添加到html中
document.documentElement.appendChild(ad_left);

//注册事件，实现关闭广告功能
ad_left.addEventListener("click",function(){
    this.style.display = "none";
});

//实现对联广告随滚动条移动
window.addEventListener("scroll",function(){
    var st1 = document.documentElement.scrollTop || document.body.scrollTop;
    ad_left.style.top = (str1 + 20) + "px";
});



//右对联广告
var ad_width2 = "100px";
var ad_height2 = "250px";
var ad_img2 = "img/ad1.jpg";
var close_img2 = "img/close.png";

var ad_right = document.createElement("div");
ad_right.style.width = ad_width2;
ad_right.style.height = ad_height2;
ad_right.style.padding = "0px";
ad_right.style.position = "absolute";
ad_right.style.right = "30px";
ad_right.style.top = "20px";

var adimg2 = document.createElement("img");
adimg2.src = ad_img2;
ad_right.appendChild(adimg2);

var closeimg2 = document.createElement("img");
closeimg2.src = close_img2;
closeimg2.style.width = "50px";
closeimg2.style.position = "relative";
closeimg2.style.left = "50px";
closeimg2.style.top = "-20px";
closeimg2.style.cursor = "pointer";
ad_right.appendChild(closeimg2);

document.documentElement.appendChild(ad_right);

ad_right.addEventListener("click",function(){
    this.style.display = "none";
});

window.addEventListener("scroll",function(){
    var st2 = document.documentElement.scrollTop || document.body.scrollTop;
    ad_right.style.top = (str2 + 20) + "px";
});



//下
var ad_width3 = "250px";
var ad_height3 = "250px";
var ad_img3 = "img/ad2.jpg";
var close_img3 = "img/close.png";

var ad_down = document.createElement("div");
ad_down.style.width = ad_width3;
ad_down.style.height = ad_height3;
ad_down.style.padding = "0px";
ad_down.style.position = "absolute";
ad_down.style.right = "180px";
ad_down.style.bottom = "20px";

var adimg3 = document.createElement("img");
adimg3.src = ad_img3;
ad_down.appendChild(adimg3);

var closeimg3 = document.createElement("img");
closeimg3.src = close_img3;
closeimg3.style.width = "50px";
closeimg3.style.position = "absolute";
closeimg3.style.right = "-50px";
closeimg3.style.bottom = "235px";
closeimg3.style.cursor = "pointer";
ad_down.appendChild(closeimg3);

document.documentElement.appendChild(ad_down);

ad_down.addEventListener("click",function(){
    this.style.display = "none";
});

window.addEventListener("scroll",function(){
    var str3 = document.documentElement.scrollBottom || document.body.scrollBottom;
    ad_down.style.bottom = str3 + "px";
});
